package com.ease.framework.gef {
   import com.ease.framework.workbench.editors.EditorInput;
   import com.ease.framework.workbench.viewer.IViewer;

   import flash.events.EventDispatcher;

   import mx.core.Container;


   /**
    * Editor类，表示编辑区域类.
    *
    * 每个Editor都会有一个Viewer视图类，用于显示视图.
    *
    * @author James Hu
    *
    */
   public class Editor extends EventDispatcher implements IEditor {
      protected var _editDomain:EditDomain;

      protected var _viewer:IViewer;

      protected var _paletteControl:Container;

      protected var _modelFactory:IModelFactory;

      protected var _editpartFactory:IEditPartFactory;

      protected var _figureFactory:IFigureFactory;

      protected var _appenderFactory:IAppenderFactory;

      public function Editor() {
         super();
         createEditDomain();
      }

      public function createPartControl(parent:Container = null):Container {
         return null;
      }

      /**
       * 子类需要实现.
       *
       */
      public function createEditDomain():void {
         setEditDomain(new EditDomain());
      }

      public function setEditDomain(ed:EditDomain):void {
         _editDomain = ed;
      }

      public function getEditDomain():EditDomain {
         return _editDomain;
      }

      public function setViewer(viewer:IViewer):void {
         _viewer = viewer;
      }

      public function getViewer():IViewer {
         if (_viewer == null) {
            _viewer = createViewer();
         }
         return _viewer;
      }

      public function createViewer():IViewer {
         return null;
      }

      public function setPaletteViewer(viewer:Container):void {
         _paletteControl = viewer;
      }

      public function getPaletteControl():Container {
         if (_viewer == null) {
            _paletteControl = createPaletteControl();
         }
         return _paletteControl;
      }

      public function createPaletteControl():Container {

         return null;
      }

      public function createModelFactory():IModelFactory {
         return null;
      }

      public function getModelFactory():IModelFactory {
         if (null == _modelFactory) {
            _modelFactory = createModelFactory();
         }

         return _modelFactory;
      }

      public function createEditPartFactory():IEditPartFactory {
         return null;
      }

      public function getEditPartFactory():IEditPartFactory {
         if (null == _editpartFactory) {
            _editpartFactory = createEditPartFactory();
         }

         return _editpartFactory;
      }

      public function createFigureFactory():IFigureFactory {
         return null;
      }

      public function getFigureFactory():IFigureFactory {
         if (null == _figureFactory) {
            _figureFactory = createFigureFactory();
         }

         return _figureFactory;
      }

      public function createAppenderFactory():IAppenderFactory {
         return null;
      }

      public function getAppenderFactory():IAppenderFactory {

         if (null == _appenderFactory) {
            _appenderFactory = createAppenderFactory();
         }

         return _appenderFactory;

      }

      public function clear():void {

      }

      public function refresh():void {

      }

      public function save():* {

      }

      public function set editorInput(value:EditorInput):void {

      }

   }
}